package cn.edu.scau.cmi.yangzemin.composite.safe;

import java.util.ArrayList;
import java.util.List;

public class SafeTeam extends SafeOrganization{
	private String name;
	private List<SafeOrganization> teamList=new ArrayList<SafeOrganization>();
	public SafeOrganization searchOrganization(String OrganizationName) {
		for(SafeOrganization safeOrganization:teamList) {
			if(safeOrganization.getName().equals(OrganizationName))
				return safeOrganization;
		}
		System.out.println("the person is not exist");
		return null; 
	}

	@Override
	public String getName() {
		return name;
	}
	public void setTeam(List<SafeOrganization> team) {
		this.teamList=team;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void addOrganization(SafeOrganization organization) {
		teamList.add(organization);
	}
	public void removeOrganization(SafeOrganization organization) {
		teamList.remove(organization);
	}
	@Override
	public void getTeam(int num) {
		String label=" ";
		int i;
		for(i=0;i<num;i++)
			label+="  ";
		System.out.println(label+this.getName()+":");
		for(SafeOrganization safeOrganization:teamList) {
			num++;
			safeOrganization.getTeam(i+1);
		}
		num--;
	}
}